package com.cloud.utils;

import java.util.Random;


public class UuidUtils {

	/**
	 * 生成id
	 */
	public static String getUUID() {
		//取当前时间的长整形值包含毫秒
		//long millis = System.currentTimeMillis();
		long millis = System.nanoTime();
		//加上五位随机数
		Random random = new Random();
		int end = random.nextInt(99999);
		//如果不足五位前面补0
		String str = millis + String.format("%05d", end);
		
		return str;
	}
	
	
	/**
	 * 生成随机函数
	 * 
	 */
	public static String genRandom(int number, String digit) {
		
		//随机数
		Random random = new Random();
		int end = random.nextInt(number);
		//如果不足五位前面补0
		String str = String.format("%0"+digit+"d", end);
		
		return str;
	}
	
	
	public static void main(String[] args) {
		for(int i=0;i< 100;i++)
		System.out.println(getUUID());
		System.out.println(genRandom(999,"3"));
	}
}
